﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Tamir.SharpSsh;

namespace IceDog.SSHConnection.SharpSSH.Client
{
    public class SharpSSHClient:IDisposable
    {
        private SshStream _sshStream;
        public SharpSSHClient(string host, string username, string password)
        {
            _sshStream = new SshStream(host, username, password);
            _sshStream.Prompt = username=="root"?"#":"$";//提示符
            _sshStream.RemoveTerminalEmulationCharacters = true;
        }
        public string Execute(string command)
        {
            
            _sshStream.Write(command);
            _sshStream.Flush();
            string response = _sshStream.ReadResponse();
            return response;
        }

        public void Dispose()
        {
            _sshStream.Close();
        }
    }
}
